$(function() {
	
	// 查询数据
	var tableObj = commonUtil.initTable({
        url : "list",
        search : true,
        detailView : true,
        pagination : true,
        columns: [
            {checkbox: true},
            {field: 'auserId', visible: true, title: 'ID'},
            {field: 'realname',align: 'center', title: '姓名',width:200},
            {field: 'gender',align: 'center', title: '性别',width:200},
            {field: 'mobile',align: 'center', title: '手机号码',width:200},
            {field: 'password',align: 'center', title: '密码',width:300},
            {field: 'isanswer',align: 'center', title: '是否回复',width:100,formatter : function(value) {return value == 1 ? "<span class='label label-success'>已回复</span>" : "<span class='label label-danger'>未回复</span>"; } },
            {field: 'answertime',align: 'center', title: '回复时间',width:300},
            // {field : 'status', title : '状态',align: 'center',width:100, formatter : function(value) {return value == 1 ? "<span class='label label-success'>开启</span>" : "<span class='label label-danger'>禁用</span>"; } },
            // {field : 'createTime', align: 'center',title : '创建时间'},
            // {field : 'companyName',align: 'center', title : '公司名称'},
            
        ]
    });

	var reply = function() {
		var list = tableObj.bootstrapTable("getSelections");
		if (list.length ==0) {
			layer.msg("请选择一条记录进行编辑",{
				offset : 't',
				anim : 6
			});
			return;
		}
		if (list.length > 1) {
			layer.msg("一次只能编辑一条记录",{
				offset : 't',
				anim : 6
			});
			return;
		}
		window.location.href = "saveUI?id="+list[0]["auserId"];
	}

	// 绑定按钮事件
	var btns = $("#btns").find("a");
	btns.each(function(index, domEle) {
		var btn = $(domEle);
		var code = btn.data("code");
		if (code == "inform:reply") {
			btn.on("click", reply);
		}
	});
});